/*

COPYRIGHT 2009 NARESHKUMAR RAO
This software is distributed under the terms of the GNU General Public License

This file is part of JSCMD.

JSCMD is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

JSCMD is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with JSCMD.  If not, see http://www.gnu.org/licenses/.

*/

document.onkeyup = handleCmd;

var getDomain = document.domain.toUpperCase()

if(getDomain=="")
{
getDomain = "C:\\RUNNING LOCALLY>"
}else{
getDomain = "C:\\"+document.domain.toUpperCase()+">"
}

var promptTitle = getDomain;


alert('Welcome To TechnoFlash Command Prompt.\nThis Program Is Made By Nareshkumar Rao');

function parseCMD()
{
var comm = fta.value.substring(promptTitle.length,fta.value.length);


sta.scrollTop=sta.scrollHeight;
//BEGINS BASIC PARSING

bcount=0;

if(comm.substring(0,5)=="echo ")
{
sta.value+="\n"+comm.substring(5,comm.length);
}else if(comm.substring(0,3)=="cls")
{
sta.value="";
}else if(comm.substring(0,8)=="ipconfig")
{
sta.value+="\nObviously You're Connected To The Internet, How Do You Think You Can Actually See This Page? Unless, You're Viewing This Locally."
}else if(comm.substring(0,5)=="color")
{
sta.style.background=comm.substring(6,comm.indexOf(","))
sta.style.color=comm.substring(comm.indexOf(",")+1,comm.length)
}else if(comm.substring(0,2)=="^G")
{
sta.value+="\nBLEEEP!";
bcount++
if(bcount>5)
{
sta.value+="ENOUGH BLEEPING ALREADY"
}
}else{
var bgcol = sta.style.background
sta.style.background="red";
setTimeout(function(){sta.style.background=bgcol}, 200);
sta.value+="\n\'"+comm.substring(0,comm.length-1)+"' is not recognized as an internel or external command, operable program or scratch file."
}

}

function handleCmd(e)
{

var keyId= (window.event) ? event.keyCode : e.keyCode;
if(keyId==13)
{

parseCMD()
fta.value=promptTitle;

}
}

function initCMD()
{
fta.style.width=window.innerWidth;
fta.style.height=window.innerHeight/2;
sta.style.width=window.innerWidth;
sta.style.height=window.innerHeight/2;
sta.style.top=window.innerHeight/2

fta.value=promptTitle;
}

function noDelete()
{
if(fta.value.substring(0,promptTitle.length)!=promptTitle)
{
fta.value=promptTitle
}
}